public class Captor {

    static int quotient(int x,int y) throws  MyException{
        if(y<0){
            throw new MyException("除数不能为负数");
        }
        return y/x;
    }

    public static void main(String[] args) {
        try{
            int result=quotient(5,-1);
        }catch(MyException e){
            System.out.println(e.getMessage());
        }catch(ArithmeticException e){
            System.out.println("除数不能为0");
        }catch(Exception e){ //所有异常的父类，顺序不能和前面的异常颠倒
            System.out.println("程序发生了异常");
        }
    }
}
